let vm = new Vue({
    el: "#vue-root",
    data: {
        account: "0x1fsda5gd5ggwe12",
        status: "进行中",
        num: 1,
        reciever: "",
        isCreator: true,
        candidates: [
            {
                name: "bear",
                tickets: 12
            },
            {
                name: "hycin",
                tickets: 12
            },
            {
                name: "toshi",
                tickets: 12
            },
            {
                name: "hello",
                tickets: 12
            }
        ],
        history: [
            {
                account: "111111111",
                reciever: "bear",
                show: true
            },
            {
                account: "222222222",
                reciever: "lfhy",
                show: true
            },
            {
                account: "222222222",
                reciever: "bear",
                show: true
            },
            {
                account: "5662132124",
                reciever: "hycin",
                show: true
            },
            {
                account: "7984512312",
                reciever: "toshi",
                show: true
            }
        ]
    },
    methods: {
        delCandidate: function (name, index) {
            console.log(name, index);
            let yes = confirm(`确定去除${name}的参选资格`);
            console.log(yes);
        }
    }
});

function buyTicket() {
    console.log("购票");
}

function vote() {
    console.log("投票", reciever.value);
}

function filter(name) {
    vm.history.forEach(obj => {
        if(name==="" || name===obj.reciever){
            obj.show = true;
        }else{
            obj.show = false;
        }
    });
}

function suspendElection() {
    console.log("终止");
}

function startElection() {
    console.log("开始");
}

function pauseElection() {
    console.log("暂停");
}

function createElection() {
    console.log("新建");
}

function addCandidate() {
    console.log("添加", document.getElementById("nameInput").value);
}

function renewCandidates(){
    console.log("更新候选人");
}

function renewHistory(){
    console.log("更新历史");
}